package com.thinkverse.recommendation.controller;

import com.thinkverse.common.result.Result;
import com.thinkverse.recommendation.service.RecommendationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 推荐控制器
 */
@RestController
@RequestMapping("/recommendation")
@RequiredArgsConstructor
public class RecommendationController {
    
    private final RecommendationService recommendationService;
    
    /**
     * 个性化推荐
     */
    @GetMapping("/personalized/{userId}")
    public Result<List<Map<String, Object>>> getPersonalizedRecommendations(@PathVariable Long userId,
                                                                           @RequestParam(defaultValue = "10") Integer size) {
        List<Map<String, Object>> recommendations = recommendationService.getPersonalizedRecommendations(userId, size);
        return Result.success(recommendations);
    }
    
    /**
     * 专家推荐
     */
    @GetMapping("/experts")
    public Result<List<Map<String, Object>>> getExpertRecommendations(@RequestParam String researchField,
                                                                    @RequestParam(defaultValue = "10") Integer size) {
        List<Map<String, Object>> experts = recommendationService.getExpertRecommendations(researchField, size);
        return Result.success(experts);
    }
    
    /**
     * 相关论文推荐
     */
    @GetMapping("/related-papers/{paperId}")
    public Result<List<Map<String, Object>>> getRelatedPapers(@PathVariable Long paperId,
                                                            @RequestParam(defaultValue = "10") Integer size) {
        List<Map<String, Object>> papers = recommendationService.getRelatedPapers(paperId, size);
        return Result.success(papers);
    }
    
    /**
     * 热门论文推荐
     */
    @GetMapping("/trending")
    public Result<List<Map<String, Object>>> getTrendingPapers(@RequestParam(defaultValue = "10") Integer size) {
        List<Map<String, Object>> papers = recommendationService.getTrendingPapers(size);
        return Result.success(papers);
    }
}
